package com.atguigu.lease.admin.service.impl;

import com.atguigu.lease.model.dto.SystemUserQueryDto;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.atguigu.lease.model.bean.SystemUser;
import com.atguigu.lease.admin.service.SystemUserService;
import com.atguigu.lease.admin.mapper.SystemUserMapper;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

/**
* @author 1
* @description 针对表【system_user(员工信息表)】的数据库操作Service实现
* @createDate 2025-09-22 17:18:51
*/
@Service
public class SystemUserServiceImpl extends ServiceImpl<SystemUserMapper, SystemUser>
    implements SystemUserService{

    @Override
    public Page<SystemUser> getPage(SystemUserQueryDto systemUserQueryDto) {
        QueryWrapper<Class<SystemUser>> queryWrapper = Wrappers.query(SystemUser.class);
        queryWrapper.like(StringUtils.hasText(systemUserQueryDto.getName()) ,
                    "t1.name",systemUserQueryDto.getName());
        queryWrapper.like(StringUtils.hasText(systemUserQueryDto.getPhone()) ,
                "t1.phone",systemUserQueryDto.getPhone());
        queryWrapper.eq("t1.is_deleted" , 0);
        return baseMapper.selectSystemUserPage(new Page<>(systemUserQueryDto.getCurrent(),systemUserQueryDto.getSize()),
                    queryWrapper
                );
    }
}




